/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.janalyse.tools

trait AutoClose {
  // Automatic resource liberation
  def using[T <: { def close}, R] (resource: T) (block: T => R) = {
    try {
      block(resource)
    } finally {
      if (resource != null) resource.close
    }
  }
}
